import { fallbackRequestPost } from '@/utils/Request'

/**
 * 请求前缀，后面后台添加网关后需要前缀选择微服务
 */
const URL_PREFIX = 'middle-goods/'

/**
 * 账号密码登陆
 * @param {AddUserCarDTO} addUserCarDTO 添加购物车数据
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const addToCar = (addUserCarDTO, successCallback = null, fullCallback = null) => {
  return fallbackRequestPost(URL_PREFIX + 'user_car/addToCar', addUserCarDTO, {}, true, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}

/**
 * 分页条件查询购物城商品详细信息
 * @param {PageDTO<UserCarQueryDTO>} pageDTO 分页查询条件
 * @param {Function} successCallback 成功回调，参数为data
 * @param {Function} fullCallback 肯定触发的回调，先于callback
 */
export const queryCarConvertGoodsByPage = (pageDTO, successCallback = null, fullCallback = null) => {
  return fallbackRequestPost(URL_PREFIX + 'user_car/queryCarConvertGoodsByPage', pageDTO, {}, false, data => {
    if (successCallback) {
      successCallback(data)
    }
  }, null, fullCallback)
}
